#region Usings

using System.Linq;
using KanbanBoard.Server.Command.DomainModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace KanbanBoard.Tests.Server.Utils.DSL {
    public static class HeyAssert {
        public static ColumnExpressionBuilder That(Task task) {
            return new ColumnExpressionBuilder(task);
        }

        public static TaskBoardAssertionExpressionBuilder That(TaskBoard taskBoard) {
            return new TaskBoardAssertionExpressionBuilder(taskBoard);
        }
    }

    public class ColumnExpressionBuilder {
        private readonly Task task;

        public ColumnExpressionBuilder(Task task) {
            this.task = task;
        }

        public BoardExpressionBuilder IsIn(string columnName) {
            return new BoardExpressionBuilder(columnName, task);
        }
    }

    public class BoardExpressionBuilder {
        private readonly string columnName;
        private readonly Task task;

        public BoardExpressionBuilder(string columnName, Task task) {
            this.columnName = columnName;
            this.task = task;
        }

        public void ColumnOf(TaskBoard board) {
            foreach (var column in board.Columns()) {
                if (column.Name() == columnName) {
                    CollectionAssert.Contains(column.Tasks(), task);
                }
                else {
                    CollectionAssert.DoesNotContain(column.Tasks(), task);
                }
            }
        }
    }
}